<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>h2o_dashboard.wave_auth &mdash; AntBot 0.0.1 documentation</title>
      <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
      <link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
      <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css?v=eafc0fe6" />

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../../_static/jquery.js?v=5d32c60e"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script src="../../_static/documentation_options.js?v=d45e8c67"></script>
        <script src="../../_static/doctools.js?v=888ff710"></script>
        <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../index.html" class="icon icon-home">
            AntBot
          </a>
              <div class="version">
                0.0.1
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../autodocumentation_python.html">autodocumentation_python</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../firebase_tools.BaseClasses.html">firebase_tools.BaseClasses</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../firebase_tools.FirestoreClient.html">firebase_tools.FirestoreClient</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../firebase_tools.authenticate.html">firebase_tools.authenticate</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../h2o_dashboard.dashboard.html">h2o_dashboard.dashboard</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../h2o_dashboard.pages.documentation_page.html">h2o_dashboard.pages.documentation_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../h2o_dashboard.pages.okx_dashbaord_page.okx_antbot_okx_premium_indicator_handler.html">h2o_dashboard.pages.okx_dashbaord_page.okx_antbot_okx_premium_indicator_handler</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../h2o_dashboard.pages.okx_dashbaord_page.okx_dashboard_page.html">h2o_dashboard.pages.okx_dashbaord_page.okx_dashboard_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../h2o_dashboard.pages.okx_streams.html">h2o_dashboard.pages.okx_streams</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../h2o_dashboard.pages.overview_page.html">h2o_dashboard.pages.overview_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../h2o_dashboard.util.html">h2o_dashboard.util</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../h2o_dashboard.wave_auth.html">h2o_dashboard.wave_auth</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.Futures_Exchange_Client.html">pyokx.Futures_Exchange_Client</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.InstrumentSearcher.html">pyokx.InstrumentSearcher</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.data_structures.html">pyokx.data_structures</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.Account.html">pyokx.low_rest_api.Account</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.BlockTrading.html">pyokx.low_rest_api.BlockTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.Convert.html">pyokx.low_rest_api.Convert</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.CopyTrading.html">pyokx.low_rest_api.CopyTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.Earning.html">pyokx.low_rest_api.Earning</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.FDBroker.html">pyokx.low_rest_api.FDBroker</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.Funding.html">pyokx.low_rest_api.Funding</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.Grid.html">pyokx.low_rest_api.Grid</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.MarketData.html">pyokx.low_rest_api.MarketData</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.NDBroker.html">pyokx.low_rest_api.NDBroker</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.PublicData.html">pyokx.low_rest_api.PublicData</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.SpreadTrading.html">pyokx.low_rest_api.SpreadTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.Status.html">pyokx.low_rest_api.Status</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.SubAccount.html">pyokx.low_rest_api.SubAccount</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.Trade.html">pyokx.low_rest_api.Trade</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.TradingData.html">pyokx.low_rest_api.TradingData</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.client.html">pyokx.low_rest_api.client</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.consts.html">pyokx.low_rest_api.consts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.exceptions.html">pyokx.low_rest_api.exceptions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.low_rest_api.utils.html">pyokx.low_rest_api.utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.market_data_service.WssMarketDataService.html">pyokx.okx_market_maker.market_data_service.WssMarketDataService</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.market_data_service.model.Instrument.html">pyokx.okx_market_maker.market_data_service.model.Instrument</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.market_data_service.model.MarkPx.html">pyokx.okx_market_maker.market_data_service.model.MarkPx</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.market_data_service.model.OrderBook.html">pyokx.okx_market_maker.market_data_service.model.OrderBook</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.market_data_service.model.Tickers.html">pyokx.okx_market_maker.market_data_service.model.Tickers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.order_management_service.WssOrderManagementService.html">pyokx.okx_market_maker.order_management_service.WssOrderManagementService</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.order_management_service.model.Order.html">pyokx.okx_market_maker.order_management_service.model.Order</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.order_management_service.model.OrderRequest.html">pyokx.okx_market_maker.order_management_service.model.OrderRequest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.position_management_service.WssPositionManagementService.html">pyokx.okx_market_maker.position_management_service.WssPositionManagementService</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.position_management_service.model.Account.html">pyokx.okx_market_maker.position_management_service.model.Account</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.position_management_service.model.BalanceAndPosition.html">pyokx.okx_market_maker.position_management_service.model.BalanceAndPosition</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.position_management_service.model.Positions.html">pyokx.okx_market_maker.position_management_service.model.Positions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.run_sample_market_maker.html">pyokx.okx_market_maker.run_sample_market_maker</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.settings.html">pyokx.okx_market_maker.settings</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.strategy.BaseStrategy.html">pyokx.okx_market_maker.strategy.BaseStrategy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.strategy.SampleMM.html">pyokx.okx_market_maker.strategy.SampleMM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.strategy.model.StrategyMeasurement.html">pyokx.okx_market_maker.strategy.model.StrategyMeasurement</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.strategy.model.StrategyOrder.html">pyokx.okx_market_maker.strategy.model.StrategyOrder</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.strategy.params.ParamsLoader.html">pyokx.okx_market_maker.strategy.params.ParamsLoader</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.strategy.risk.RiskCalculator.html">pyokx.okx_market_maker.strategy.risk.RiskCalculator</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.strategy.risk.RiskSnapshot.html">pyokx.okx_market_maker.strategy.risk.RiskSnapshot</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.tests.test_strategy.html">pyokx.okx_market_maker.tests.test_strategy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.utils.InstrumentUtil.html">pyokx.okx_market_maker.utils.InstrumentUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.utils.OkxEnum.html">pyokx.okx_market_maker.utils.OkxEnum</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.utils.TdModeUtil.html">pyokx.okx_market_maker.utils.TdModeUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.okx_market_maker.utils.WsOrderUtil.html">pyokx.okx_market_maker.utils.WsOrderUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.redis_structured_reports.html">pyokx.redis_structured_reports</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.redis_structured_streams.html">pyokx.redis_structured_streams</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.rest_handling.html">pyokx.rest_handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.rest_messages_service.html">pyokx.rest_messages_service</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.strategy_handling.html">pyokx.strategy_handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.AccountTest.html">pyokx.test.AccountTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.BlockTradingTest.html">pyokx.test.BlockTradingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.BrokerTest.html">pyokx.test.BrokerTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.ConvertTest.html">pyokx.test.ConvertTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.CopyTradingTest.html">pyokx.test.CopyTradingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.EarningTest.html">pyokx.test.EarningTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.FundingTest.html">pyokx.test.FundingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.GridTest.html">pyokx.test.GridTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.MarketTest.html">pyokx.test.MarketTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.PublicDataTest.html">pyokx.test.PublicDataTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.SpreadTest.html">pyokx.test.SpreadTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.StackingTest.html">pyokx.test.StackingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.SubAccountTest.html">pyokx.test.SubAccountTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.TradeTest.html">pyokx.test.TradeTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.TradingDataTest.html">pyokx.test.TradingDataTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.WsPrivateAsyncTest.html">pyokx.test.WsPrivateAsyncTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.test.WsPublicAsyncTest.html">pyokx.test.WsPublicAsyncTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.websocket_handling.html">pyokx.websocket_handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.ws_clients.WebSocketFactory.html">pyokx.ws_clients.WebSocketFactory</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.ws_clients.WsPprivateAsync.html">pyokx.ws_clients.WsPprivateAsync</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.ws_clients.WsPublicAsync.html">pyokx.ws_clients.WsPublicAsync</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.ws_clients.WsUtils.html">pyokx.ws_clients.WsUtils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pyokx.ws_data_structures.html">pyokx.ws_data_structures</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../redis_tools.config.html">redis_tools.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../redis_tools.consumers.html">redis_tools.consumers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../redis_tools.utils.html">redis_tools.utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rest_app.html">rest_app</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../routers.api_keys.html">routers.api_keys</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../routers.login.html">routers.login</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../routers.okx.html">routers.okx</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../routers.okx_authentication.html">routers.okx_authentication</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../routers.signup.html">routers.signup</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../shared.command_execution.html">shared.command_execution</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../shared.config.html">shared.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../shared.configuration_parser.html">shared.configuration_parser</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../shared.data_processing_utils.html">shared.data_processing_utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../shared.file_directory_ops.html">shared.file_directory_ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../shared.logging.html">shared.logging</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../shared.string_dict_utils.html">shared.string_dict_utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../shared.tmp_shared.html">shared.tmp_shared</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../tradingview_tools.tradingview_widgets.html">tradingview_tools.tradingview_widgets</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../websocket_app.html">websocket_app</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">AntBot</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
      <li class="breadcrumb-item active">h2o_dashboard.wave_auth</li>
      <li class="wy-breadcrumbs-aside">
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <h1>Source code for h2o_dashboard.wave_auth</h1><div class="highlight"><pre>
<span></span>

<span class="kn">import</span> <span class="nn">asyncio</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">os</span>

<span class="kn">import</span> <span class="nn">dotenv</span>
<span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">from</span> <span class="nn">h2o_wave</span> <span class="kn">import</span> <span class="n">Q</span><span class="p">,</span> <span class="n">app</span><span class="p">,</span> <span class="n">ui</span><span class="p">,</span> <span class="n">on</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">run_on</span><span class="p">,</span> <span class="n">AsyncSite</span>  <span class="c1"># noqa F401</span>

<span class="kn">from</span> <span class="nn">firebase_tools.authenticate</span> <span class="kn">import</span> <span class="n">authenticate_with_firebase</span><span class="p">,</span> <span class="n">check_str_token_validity</span>
<span class="kn">from</span> <span class="nn">h2o_dashboard.pages.documentation_page</span> <span class="kn">import</span> <span class="n">documentation_page</span>
<span class="kn">from</span> <span class="nn">h2o_dashboard.pages.okx_dashbaord_page.okx_dashboard_page</span> <span class="kn">import</span> <span class="n">okx_dashboard_page</span>
<span class="kn">from</span> <span class="nn">h2o_dashboard.pages.overview_page</span> <span class="kn">import</span> <span class="n">overview_page</span>
<span class="kn">from</span> <span class="nn">h2o_dashboard.util</span> <span class="kn">import</span> <span class="n">add_card</span><span class="p">,</span> <span class="n">clear_cards</span>

<span class="n">dotenv</span><span class="o">.</span><span class="n">load_dotenv</span><span class="p">(</span><span class="n">dotenv</span><span class="o">.</span><span class="n">find_dotenv</span><span class="p">())</span>

<span class="n">FIREBASE_CONFIG</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s2">&quot;apiKey&quot;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;FIREBASE_API_KEY&quot;</span><span class="p">),</span>
<span class="p">}</span>

<span class="k">assert</span> <span class="n">FIREBASE_CONFIG</span><span class="p">[</span><span class="s2">&quot;apiKey&quot;</span><span class="p">],</span> <span class="s2">&quot;FIREBASE_API_KEY environment variable not set!&quot;</span>


<div class="viewcode-block" id="init">
<a class="viewcode-back" href="../../h2o_dashboard.wave_auth.html#h2o_dashboard.wave_auth.init">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">init</span><span class="p">(</span><span class="n">q</span><span class="p">:</span> <span class="n">Q</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Q Page Meta (meta_card) Arguments:</span>
<span class="sd">        box</span>
<span class="sd">            A string indicating how to place this component on the page.</span>
<span class="sd">        title</span>
<span class="sd">            The title of the page.</span>
<span class="sd">        refresh</span>
<span class="sd">            Refresh rate in seconds. A value of 0 turns off live-updates. Values != 0 are currently ignored (reserved for future use).</span>
<span class="sd">        notification</span>
<span class="sd">            Display a desktop notification.</span>
<span class="sd">        notification_bar</span>
<span class="sd">            Display an in-app notification bar.</span>
<span class="sd">        redirect</span>
<span class="sd">            Redirect the page to a new URL.</span>
<span class="sd">        icon</span>
<span class="sd">            Shortcut icon path. Preferably a .png file (.ico files may not work in mobile browsers). Not supported in Safari.</span>
<span class="sd">        layouts</span>
<span class="sd">            The layouts supported by this page.</span>
<span class="sd">        dialog</span>
<span class="sd">            Display a dialog on the page.</span>
<span class="sd">        side_panel</span>
<span class="sd">            Display a side panel on the page.</span>
<span class="sd">        theme</span>
<span class="sd">            Specify the name of the theme (color scheme) to use on this page. One of &#39;light&#39;, &#39;neon&#39; or &#39;h2o-dark&#39;.</span>
<span class="sd">        themes</span>
<span class="sd">            Themes (color schemes) that define color used in the app.</span>
<span class="sd">        tracker</span>
<span class="sd">            Configure a tracker for the page (for web analytics).</span>
<span class="sd">        scripts</span>
<span class="sd">            External Javascript files to load into the page.</span>
<span class="sd">        script</span>
<span class="sd">            Javascript code to execute on this page.</span>
<span class="sd">        stylesheet</span>
<span class="sd">            CSS stylesheet to be applied to this page.</span>
<span class="sd">        stylesheets</span>
<span class="sd">            External CSS files to load into the page.</span>
<span class="sd">        commands</span>
<span class="sd">            Contextual menu commands for this component.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Static Business Website</span>
    <span class="c1"># index_file = open(&#39;static/html/index.html&#39;, &#39;r&#39;).read()</span>

    <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="p">[</span><span class="s1">&#39;meta&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">ui</span><span class="o">.</span><span class="n">meta_card</span><span class="p">(</span><span class="n">box</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
                                  <span class="n">title</span><span class="o">=</span><span class="s1">&#39;AntBot&#39;</span><span class="p">,</span>
                                  <span class="n">layouts</span><span class="o">=</span><span class="p">[</span><span class="n">ui</span><span class="o">.</span><span class="n">layout</span><span class="p">(</span><span class="nb">breakpoint</span><span class="o">=</span><span class="s1">&#39;xs&#39;</span><span class="p">,</span> <span class="n">min_height</span><span class="o">=</span><span class="s1">&#39;100vh&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;default&#39;</span><span class="p">,</span>
                                                     <span class="n">zones</span><span class="o">=</span><span class="p">[</span>
                                      <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;main&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">zones</span><span class="o">=</span><span class="p">[</span>
                                          <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;sidebar&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;180px&#39;</span><span class="p">),</span>
                                          <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">,</span> <span class="n">zones</span><span class="o">=</span><span class="p">[</span>
                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;header&#39;</span><span class="p">),</span>
                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;content&#39;</span><span class="p">,</span> <span class="n">zones</span><span class="o">=</span><span class="p">[</span>
                                                  <span class="c1"># Specify various zones and use the one that is currently needed. Empty zones are ignored.</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;first_context&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;0 0 1 4&#39;</span><span class="p">,</span>
                                                          <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span>
                                                          <span class="n">zones</span><span class="o">=</span><span class="p">[</span>
                                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;first_context_1&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">),</span>
                                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;first_context_2&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">),</span>
                                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;first_context_3&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">),</span>
                                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;first_context_4&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">),</span>
                                                          <span class="p">]),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;second_context&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;0 0 1 4&#39;</span><span class="p">,</span>
                                                          <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span>
                                                          <span class="n">zones</span><span class="o">=</span><span class="p">[</span>
                                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;second_context_1&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">),</span>
                                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;second_context_2&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">),</span>
                                                              <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;second_context_3&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">,</span>
                                                                      <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span>
                                                                      <span class="n">zones</span><span class="o">=</span><span class="p">[</span>
                                                                          <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;second_context_3_1&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">),</span>
                                                                          <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;second_context_3_2&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 4 0 0&#39;</span><span class="p">)</span>
                                                                      <span class="p">]),</span>
                                                          <span class="p">]),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;details&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;4 4 4 4&#39;</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;horizontal&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;centered&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1 1 1 1&#39;</span><span class="p">,</span> <span class="n">align</span><span class="o">=</span><span class="s1">&#39;center&#39;</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;vertical&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;1&#39;</span><span class="p">),</span>
                                                  <span class="c1"># Wrapping = &#39;start&#39;, &#39;end&#39;, &#39;center&#39;, &#39;between&#39;, &#39;around&#39;, &#39;stretch&#39;</span>
                                                  <span class="c1"># Layout = &#39;start&#39;, &#39;end&#39;, &#39;center&#39;, &#39;between&#39;, &#39;around&#39;</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;grid_1&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">wrap</span><span class="o">=</span><span class="s1">&#39;stretch&#39;</span><span class="p">,</span>
                                                          <span class="n">justify</span><span class="o">=</span><span class="s1">&#39;center&#39;</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;grid_2&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">wrap</span><span class="o">=</span><span class="s1">&#39;stretch&#39;</span><span class="p">,</span>
                                                          <span class="n">justify</span><span class="o">=</span><span class="s1">&#39;start&#39;</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;grid_3&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">wrap</span><span class="o">=</span><span class="s1">&#39;stretch&#39;</span><span class="p">,</span>
                                                          <span class="n">justify</span><span class="o">=</span><span class="s1">&#39;center&#39;</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;grid_4&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">wrap</span><span class="o">=</span><span class="s1">&#39;stretch&#39;</span><span class="p">,</span>
                                                          <span class="n">justify</span><span class="o">=</span><span class="s1">&#39;center&#39;</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;grid_5&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">wrap</span><span class="o">=</span><span class="s1">&#39;stretch&#39;</span><span class="p">,</span>
                                                          <span class="n">justify</span><span class="o">=</span><span class="s1">&#39;center&#39;</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;grid_6&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">wrap</span><span class="o">=</span><span class="s1">&#39;stretch&#39;</span><span class="p">,</span>
                                                          <span class="n">justify</span><span class="o">=</span><span class="s1">&#39;center&#39;</span><span class="p">),</span>
                                                  <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;bot_manual_controls&#39;</span><span class="p">,</span>
                                                            <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span>
                                                          <span class="c1"># Cover the entire card</span>
                                                            <span class="n">wrap</span><span class="o">=</span><span class="s1">&#39;stretch&#39;</span><span class="p">,</span>

                                                            <span class="p">),</span>
                                              <span class="p">]),</span>
                                          <span class="p">]),</span>
                                      <span class="p">]),</span>
                                      <span class="n">ui</span><span class="o">.</span><span class="n">zone</span><span class="p">(</span><span class="s1">&#39;footer&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="s1">&#39;0 1 0 0&#39;</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="n">ui</span><span class="o">.</span><span class="n">ZoneDirection</span><span class="o">.</span><span class="n">ROW</span><span class="p">),</span>
                                  <span class="p">]),</span>
                                           <span class="p">],</span>
                                  <span class="n">themes</span><span class="o">=</span><span class="p">[</span>
                                      <span class="n">ui</span><span class="o">.</span><span class="n">theme</span><span class="p">(</span>
                                          <span class="n">name</span><span class="o">=</span><span class="s1">&#39;my-awesome-theme&#39;</span><span class="p">,</span>
                                          <span class="n">primary</span><span class="o">=</span><span class="s1">&#39;#8C1B11&#39;</span><span class="p">,</span>  <span class="c1"># Header and Sidebaer - Color Light Red</span>
                                          <span class="n">text</span><span class="o">=</span><span class="s1">&#39;#000000&#39;</span><span class="p">,</span>  <span class="c1">#</span>
                                          <span class="n">card</span><span class="o">=</span><span class="s1">&#39;#ffffff&#39;</span><span class="p">,</span>
                                          <span class="n">page</span><span class="o">=</span><span class="s1">&#39;#F2F2F2&#39;</span><span class="p">,</span>
                                          <span class="c1"># page=&#39;#D91A1A&#39;,</span>

                                      <span class="p">),</span>
                                      <span class="n">ui</span><span class="o">.</span><span class="n">theme</span><span class="p">(</span>
                                          <span class="n">name</span><span class="o">=</span><span class="s1">&#39;my-awesome-theme1&#39;</span><span class="p">,</span>
                                          <span class="n">primary</span><span class="o">=</span><span class="s1">&#39;#571305&#39;</span><span class="p">,</span>  <span class="c1"># Header and Sidebaer - Color Light Red</span>
                                          <span class="n">text</span><span class="o">=</span><span class="s1">&#39;#E0E0E0&#39;</span><span class="p">,</span>  <span class="c1">#</span>
                                          <span class="n">card</span><span class="o">=</span><span class="s1">&#39;#333333&#39;</span><span class="p">,</span>
                                          <span class="n">page</span><span class="o">=</span><span class="s1">&#39;#121212&#39;</span><span class="p">,</span>

                                      <span class="p">),</span>
                                      <span class="n">ui</span><span class="o">.</span><span class="n">theme</span><span class="p">(</span>
                                          <span class="n">name</span><span class="o">=</span><span class="s1">&#39;my-awesome-theme2&#39;</span><span class="p">,</span>
                                          <span class="n">primary</span><span class="o">=</span><span class="s1">&#39;#2979FF&#39;</span><span class="p">,</span>  <span class="c1"># Header and Sidebaer - Color Light Red</span>
                                          <span class="n">text</span><span class="o">=</span><span class="s1">&#39;#E0E0E0&#39;</span><span class="p">,</span>  <span class="c1">#</span>
                                          <span class="n">card</span><span class="o">=</span><span class="s1">&#39;#212121&#39;</span><span class="p">,</span>
                                          <span class="n">page</span><span class="o">=</span><span class="s1">&#39;#000000&#39;</span><span class="p">,</span>

                                      <span class="p">)</span>
                                  <span class="p">],</span>
                                  <span class="n">theme</span><span class="o">=</span><span class="s1">&#39;my-awesome-theme2&#39;</span>
                                  <span class="p">)</span>

    <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">initialized</span> <span class="o">=</span> <span class="kc">False</span></div>



<div class="viewcode-block" id="initialize_client">
<a class="viewcode-back" href="../../h2o_dashboard.wave_auth.html#h2o_dashboard.wave_auth.initialize_client">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">initialize_client</span><span class="p">(</span><span class="n">q</span><span class="p">:</span> <span class="n">Q</span><span class="p">):</span>
    <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">cards</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
    <span class="k">await</span> <span class="n">init</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
    <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">initialized</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">token</span> <span class="o">=</span> <span class="kc">None</span>  <span class="c1"># Initially, no token is set.</span></div>






<div class="viewcode-block" id="render_login_page">
<a class="viewcode-back" href="../../h2o_dashboard.wave_auth.html#h2o_dashboard.wave_auth.render_login_page">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">render_login_page</span><span class="p">(</span><span class="n">q</span><span class="p">:</span> <span class="n">Q</span><span class="p">,</span> <span class="n">error_message</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Render the login page.&quot;&quot;&quot;</span>

    <span class="k">await</span> <span class="n">clear_cards</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
    <span class="n">items</span> <span class="o">=</span> <span class="p">[</span>
        <span class="n">ui</span><span class="o">.</span><span class="n">message_bar</span><span class="p">(</span><span class="nb">type</span><span class="o">=</span><span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s1">&#39;Please login to continue.&#39;</span><span class="p">,</span> <span class="p">),</span>
        <span class="n">ui</span><span class="o">.</span><span class="n">text_xl</span><span class="p">(</span><span class="s1">&#39;Login&#39;</span><span class="p">),</span>
        <span class="n">ui</span><span class="o">.</span><span class="n">textbox</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;email&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;Email&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span>
        <span class="n">ui</span><span class="o">.</span><span class="n">textbox</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;password&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;Password&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span>
        <span class="n">ui</span><span class="o">.</span><span class="n">buttons</span><span class="p">([</span><span class="n">ui</span><span class="o">.</span><span class="n">button</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;login&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;Login&#39;</span><span class="p">,</span> <span class="n">primary</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="p">)]),</span>
    <span class="p">]</span>
    <span class="k">if</span> <span class="n">error_message</span><span class="p">:</span>
        <span class="n">items</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">ui</span><span class="o">.</span><span class="n">message_bar</span><span class="p">(</span><span class="nb">type</span><span class="o">=</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="n">error_message</span><span class="p">,</span> <span class="p">))</span>

    <span class="k">await</span> <span class="n">add_card</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="s1">&#39;login&#39;</span><span class="p">,</span> <span class="n">ui</span><span class="o">.</span><span class="n">form_card</span><span class="p">(</span><span class="n">box</span><span class="o">=</span><span class="s1">&#39;centered&#39;</span><span class="p">,</span> <span class="n">items</span><span class="o">=</span><span class="n">items</span><span class="p">,</span> <span class="p">),</span> <span class="p">)</span></div>


    <span class="c1"># Lets add decorations to the login page</span>


<div class="viewcode-block" id="add_application_sidebar">
<a class="viewcode-back" href="../../h2o_dashboard.wave_auth.html#h2o_dashboard.wave_auth.add_application_sidebar">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">add_application_sidebar</span><span class="p">(</span><span class="n">q</span><span class="p">):</span>
    <span class="n">image_address</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="c1"># image_address = &#39;&#39;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;#&quot;</span><span class="p">]:</span>
        <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">&#39;#&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;overview_page&#39;</span>

    <span class="k">await</span> <span class="n">add_card</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="s1">&#39;Application_Sidebar&#39;</span><span class="p">,</span> <span class="n">ui</span><span class="o">.</span><span class="n">nav_card</span><span class="p">(</span>
        <span class="n">box</span><span class="o">=</span><span class="s1">&#39;sidebar&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;primary&#39;</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s1">&#39;AntBot&#39;</span><span class="p">,</span>
        <span class="n">subtitle</span><span class="o">=</span><span class="s2">&quot;just a tiny bot here to help you out&quot;</span><span class="p">,</span>
        <span class="n">value</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;#</span><span class="si">{</span><span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;#&quot;</span><span class="p">]</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">,</span>
        <span class="c1"># image=&#39;https://wave.h2o.ai/img/h2o-logo.svg&#39;, items=[]</span>
        <span class="c1"># Loading from local file rather than url</span>
        <span class="n">image</span><span class="o">=</span><span class="n">image_address</span><span class="p">,</span>
        <span class="n">items</span><span class="o">=</span><span class="p">[</span>
            <span class="n">ui</span><span class="o">.</span><span class="n">nav_group</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">items</span><span class="o">=</span><span class="p">[</span>
                <span class="n">ui</span><span class="o">.</span><span class="n">nav_item</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;#overview_page&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;Overview&#39;</span><span class="p">,</span> <span class="n">icon</span><span class="o">=</span><span class="s1">&#39;Home&#39;</span><span class="p">),</span>
                <span class="n">ui</span><span class="o">.</span><span class="n">nav_item</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;#okx_dashboard_page&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;OKX Dashboard&#39;</span><span class="p">,</span> <span class="n">icon</span><span class="o">=</span><span class="s1">&#39;eDiscoveryApp&#39;</span><span class="p">),</span>
                <span class="n">ui</span><span class="o">.</span><span class="n">nav_item</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;#documentation_page&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;Documentation&#39;</span><span class="p">,</span> <span class="n">icon</span><span class="o">=</span><span class="s1">&#39;Document&#39;</span><span class="p">),</span>
            <span class="p">]),</span>
            <span class="c1"># ui.nav_group(&#39;Docs&#39;, items=[</span>
            <span class="c1">#     ui.nav_item(name=&#39;#admin_userdocs_link&#39;, label=&#39;Usage Documentation&#39;, icon=&#39;TextDocumentShared&#39;),</span>
            <span class="c1">#     ui.nav_item(name=&#39;#admin_devdocs_link&#39;, label=&#39;Codebase Documentation&#39;, icon=&#39;TextDocumentEdit&#39;),</span>
            <span class="c1"># ]),</span>
            <span class="c1"># ui.nav_group(&#39;Account&#39;, items=[</span>
            <span class="c1">#     ui.nav_item(name=&#39;#admin_account_page&#39;, label=&#39;Account&#39;, icon=&#39;AccountManagement&#39;),</span>
            <span class="c1">#     ui.nav_item(name=&#39;#admin_plans_page&#39;, label=&#39;Plans&#39;, icon=&#39;PaymentCard&#39;),</span>
            <span class="c1">#     ui.nav_item(name=&#39;logout&#39;, label=&#39;Logout&#39;, icon=&#39;Logout&#39;),</span>
            <span class="c1"># ]),</span>

        <span class="p">],</span>
    <span class="p">))</span></div>




<div class="viewcode-block" id="render_hidden_content">
<a class="viewcode-back" href="../../h2o_dashboard.wave_auth.html#h2o_dashboard.wave_auth.render_hidden_content">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">render_hidden_content</span><span class="p">(</span><span class="n">q</span><span class="p">:</span> <span class="n">Q</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Render pages content e.g. overview_page or other pages get added here</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">await</span> <span class="n">add_application_sidebar</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
    <span class="k">await</span> <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

    <span class="c1"># What path is the user at right now</span>
    <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;Path: </span><span class="si">{</span><span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;#&quot;</span><span class="p">]</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>



    <span class="k">if</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">&#39;#&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;overview_page&#39;</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Route to Overview Page&quot;</span><span class="p">)</span>
        <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">okx_dashboard_page_running_event</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
        <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">documentation_page_running_event</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">overview_page_running_event</span><span class="o">.</span><span class="n">is_set</span><span class="p">():</span>
            <span class="k">await</span> <span class="n">clear_cards</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
            <span class="k">await</span> <span class="n">add_application_sidebar</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
            <span class="k">await</span> <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">overview_page_running_event</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">overview_page_task</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span><span class="n">overview_page</span><span class="p">(</span><span class="n">q</span><span class="p">,</span><span class="n">update_seconds</span><span class="o">=</span><span class="mi">1</span><span class="p">))</span>
        <span class="k">await</span> <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>

    <span class="k">elif</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">&#39;#&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;okx_dashboard_page&#39;</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Route to OKX Dashboard Page&quot;</span><span class="p">)</span>
        <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">overview_page_running_event</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
        <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">documentation_page_running_event</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">okx_dashboard_page_running_event</span><span class="o">.</span><span class="n">is_set</span><span class="p">():</span>
            <span class="k">await</span> <span class="n">clear_cards</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
            <span class="k">await</span> <span class="n">add_application_sidebar</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
            <span class="k">await</span> <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">okx_dashboard_page_running_event</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">okx_dashboard_page_task</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span><span class="n">okx_dashboard_page</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="n">update_seconds</span><span class="o">=</span><span class="mi">1</span><span class="p">))</span>
        <span class="k">await</span> <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
    <span class="k">elif</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">&#39;#&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;documentation_page&#39;</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Route to Documentation Page&quot;</span><span class="p">)</span>
        <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">overview_page_running_event</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
        <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">okx_dashboard_page_running_event</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">documentation_page_running_event</span><span class="o">.</span><span class="n">is_set</span><span class="p">():</span>
            <span class="k">await</span> <span class="n">clear_cards</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
            <span class="k">await</span> <span class="n">add_application_sidebar</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
            <span class="k">await</span> <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">documentation_page_running_event</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">documentation_page_task</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span><span class="n">documentation_page</span><span class="p">(</span><span class="n">q</span><span class="p">))</span>
        <span class="k">await</span> <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Error: No route found&quot;</span><span class="p">)</span>

    <span class="k">await</span> <span class="n">q</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">save</span><span class="p">()</span></div>



<div class="viewcode-block" id="serve_security">
<a class="viewcode-back" href="../../h2o_dashboard.wave_auth.html#h2o_dashboard.wave_auth.serve_security">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">serve_security</span><span class="p">(</span><span class="n">q</span><span class="p">:</span> <span class="n">Q</span><span class="p">,</span> <span class="n">bypass_security</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
    <span class="n">response</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="c1"># If logout is triggered, clear token and show login page</span>
    <span class="k">if</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">logout</span><span class="p">:</span>
        <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">token</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">await</span> <span class="n">render_login_page</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
        <span class="k">return</span>  <span class="c1"># End the function after logging out</span>

    <span class="c1"># If login is triggered, try to authenticate and decide what to render next</span>
    <span class="k">if</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">login</span><span class="p">:</span>
        <span class="n">response</span> <span class="o">=</span> <span class="k">await</span> <span class="n">authenticate_with_firebase</span><span class="p">(</span><span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">email</span><span class="p">,</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">password</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">response</span><span class="p">[</span><span class="s1">&#39;status&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;success&#39;</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Token already exists and is valid&quot;</span><span class="p">)</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">token</span> <span class="o">=</span> <span class="n">response</span><span class="p">[</span><span class="s1">&#39;token&#39;</span><span class="p">]</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">user_id</span> <span class="o">=</span> <span class="n">response</span><span class="p">[</span><span class="s1">&#39;user_id&#39;</span><span class="p">]</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">email</span> <span class="o">=</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">email</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">expires_in</span> <span class="o">=</span> <span class="n">response</span><span class="p">[</span><span class="s1">&#39;expires_in&#39;</span><span class="p">]</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">password</span> <span class="o">=</span> <span class="n">q</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">password</span>


            <span class="k">await</span> <span class="n">render_login_page</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="n">error_message</span><span class="o">=</span><span class="n">response</span><span class="p">[</span><span class="s1">&#39;error_message&#39;</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">token</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">user_id</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">email</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">expires_in</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">password</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">await</span> <span class="n">render_login_page</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="n">error_message</span><span class="o">=</span><span class="n">response</span><span class="p">[</span><span class="s1">&#39;error_message&#39;</span><span class="p">])</span>
            <span class="k">return</span>  <span class="c1"># End the function if login fails</span>

    <span class="k">if</span> <span class="n">bypass_security</span><span class="p">:</span>
        <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">token</span> <span class="o">=</span> <span class="s1">&#39;bypass&#39;</span>
        <span class="k">await</span> <span class="n">render_hidden_content</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="c1"># If the client already has a token, check its validity and act accordingly</span>
    <span class="k">if</span> <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">token</span><span class="p">:</span>
        <span class="k">if</span> <span class="k">await</span> <span class="n">check_str_token_validity</span><span class="p">(</span><span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">token</span><span class="p">):</span>
            <span class="n">context</span> <span class="o">=</span> <span class="n">response</span>  <span class="c1"># todo: implement better context handling</span>
            <span class="k">await</span> <span class="n">render_hidden_content</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">q</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">token</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">await</span> <span class="n">render_login_page</span><span class="p">(</span><span class="n">q</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">await</span> <span class="n">render_login_page</span><span class="p">(</span><span class="n">q</span><span class="p">)</span></div>

</pre></div>

           </div>
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2024, Ruben Fernandez Carbon.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>